package sg.edu.nus.iss.billing.template;

import sg.edu.nus.iss.billing.entity.Address;

/**
 * @author Daniel
 *
 */
public class AddressParseAction extends BasicParseAction {
	
	public AddressParseAction(String parseKey, Address address) {
		super(parseKey, "");
		String parseValue = "";
		StringBuffer addressValue = new StringBuffer();
		if (address.getUnitNo() != null && !"".equals(address.getUnitNo())) {
			addressValue.append(address.getUnitNo());
			addressValue.append(",");
		}
		if (address.getAddressLine1() != null && !"".equals(address.getAddressLine1())) {
			addressValue.append(address.getAddressLine1());
			addressValue.append(",");
		}
		if (addressValue.toString().length() > 0) {
			addressValue.append("<br>");
		}
		if (address.getAddressLine2() != null && !"".equals(address.getAddressLine2())) {
			addressValue.append(address.getAddressLine2());
			addressValue.append(",");
		}
		if (addressValue.toString().length() > 0) {
			addressValue.append("<br>");
		}
		addressValue.append("Singapore ");
		addressValue.append(address.getPostalCode());
		setParseValue(addressValue.toString());
	}

}
